<template>
  <div class="header">
    <div class="header-content">
      <div class="nav-link">
        <ul class="nav-link-ul">
          <li class="nav-link-item">
            <router-link :to="{path : '/'}">
              <SvgIcon iconClass="logo">
              </SvgIcon>
              首页
            </router-link>
          </li>
        </ul>
      </div>
      <SearchBox></SearchBox>
      <div class="nav-user-center">
        <Avatar></Avatar>
        <div
          v-for="(item, index) in userAreaList"
          :key="index"
          @click="userItemRedirect(item)"
        >
          <div class="item">{{ item.text }}</div>
        </div>
      </div>
      <div>
        <div @click="handleUploadClick" class="upload">投稿</div>
      </div>
    </div>
  </div>
</template>
<script>
import Avatar from "./Avatar.vue";
import SearchBox from './SearchBox.vue';

export default {
  components: { Avatar, SearchBox },
  data() {
    return {
      keyword: "",
      userAreaList: [
        { name: "message", text: "消息" },
        { name: "news", text: "动态" },
        { name: "star", text: "收藏" },
        { name: "history", text: "历史" },
        { name: "platform", text: "创作中心" },
      ],
    };
  },
  methods: {
    userItemRedirect(item) {
      let itemUrl = this.$router.resolve({
        name: item.name,
        params: { uuid: this.$store.getters.uuid },
      });
      window.open(itemUrl.href, "_blank");
    },
    handleUploadClick() {
      let uploadUrl = this.$router.resolve({
        name: 'upload',
      });
      window.open(uploadUrl.href, "_blank");
    }
  },
};
</script>
<style scoped>
.header {
  z-index: 1;
  width: 100%;
  height: 56px;
  box-sizing: border-box;
  box-shadow: 0 2px 4px 0 rgb(0 0 0 / 8%);
  border: 0;
  background-color: white;
}
.header-content {
  box-sizing: border-box;
  padding: 10px 22px;
  line-height: 30px;
  position: relative;
  margin: 0 auto;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}
.nav-logo {
  margin-right: 6px;
  height: 36px;
  vertical-align: middle;
}
.nav-link {
  padding: 0;
  margin: 0;
  border: none;
}

.nav-link-ul {
  height: 36px;
  display: flex;
  align-items: center;
  list-style: none;
  font-weight: bold;
}
.nav-link-item {
  margin-right: 12px;
  list-style: none;
  white-space: nowrap;
}

.nav-user-center {
  display: flex;
  flex-shrink: 0;
}

.item {
  display: flex;
  margin-left: 12px;
  position: relative;
  cursor: pointer;
  white-space: nowrap;
  line-height: 36px;
}
.upload {
  display: block;
  width: 60px;
  position: relative;
  cursor: pointer;
  font-size: 14px;
  color: white;
  background-color: #00d684;
  /* height: 36px; */
  line-height: 36px;
  text-align: center;
  border-radius: 2px;
  margin-left: 14px;
  font-weight: 600;
}
.item:hover,
upload:hover,
.nav-search-submit:hover {
  color: green;
}

a {
  color: black;
  text-decoration: none;
  transition: color 0.3s;
}

a:hover {
  color: green;
}
</style>